<template>
  <div id="app">
    <h1>{{msg}}</h1>
    <button @click="handle">点我啊</button>
    {{value}}
  </div>
</template>
<script>

const children = require.context('../components', false, /^\.\/com\-(\w+)\.js$/)
const componentsList = {}
if (children) {
  children.keys().forEach(key => {
    console.log('key', key)
    let obj = children(key)
    const fixKey = key.replace(/\.\//, '').replace(/\.js/, '')
    console.log('fixKey', fixKey)
    componentsList[fixKey] = obj.default
  })
}


export default {
  name: 'App',
  data() {
    return {
      msg: '手工创建的Vue项目',
      value: componentsList
    }
  },
  methods: {
    handle () {
      alert('你真点了 ~_!')
    }
  }
}
</script>